package com.pearadmin.pro.modules.ser.service.impl;

import cn.hutool.core.codec.Base64;
import cn.hutool.crypto.SecureUtil;
import cn.hutool.crypto.symmetric.SymmetricAlgorithm;
import cn.hutool.crypto.symmetric.SymmetricCrypto;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.pearadmin.pro.common.web.base.page.PageResponse;
import com.pearadmin.pro.common.web.base.page.Pageable;
import com.pearadmin.pro.modules.ser.domain.Coffer;
import com.pearadmin.pro.modules.ser.param.CofferRequest;
import com.pearadmin.pro.modules.ser.repository.CofferRepository;
import com.pearadmin.pro.modules.ser.service.CofferService;
import com.pearadmin.pro.modules.sys.domain.SysDict;
import com.pearadmin.pro.modules.sys.param.SysDictRequest;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * Author: didiplus
 * Email: 972479352@qq.com
 * CreateTime: 2022/3/7
 * Desc: 密码表Service业务层处理
 */
@Service
public class CofferServiceImpl extends ServiceImpl<CofferRepository, Coffer> implements CofferService {

    @Resource
    CofferRepository cofferRepository;

    @Override
    public List<Coffer> list(CofferRequest request) {
        return cofferRepository.selectcofferInfo(request);
    }

    @Override
    public PageResponse<Coffer> page(CofferRequest request) {
        return Pageable.of(request,(()-> cofferRepository.selectcofferInfo(request)));
    }


//    @Override
//    public boolean save(Coffer entity) {
//        byte[] key = SecureUtil.generateKey(SymmetricAlgorithm.AES.getValue()).getEncoded();
//        SymmetricCrypto aes = new SymmetricCrypto(SymmetricAlgorithm.AES, key);
//        byte[] encrypt = aes.encrypt(entity.getPassword());
//        entity.setPassword(Base64.encode(encrypt));
//        return super.save(entity);
//
//    }
}
